﻿using Huirui.Cavan.Domain.Seedwork;
using System;
using System.Collections;
using System.Collections.Generic;

namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    #region Account

    /// <summary>
    /// Account object for NHibernate mapped table 'Account'.
    /// </summary>
    [Serializable]
    public class Account : Persistent<string>
    {
        #region Member Variables

        protected string _name;
        protected string _currency;
        protected SystemIdentifier.AccountType _type;
        protected SystemIdentifier.AccountStatus _status;
        protected DateTime _initialDate;
        protected decimal _initialAmount;
        protected decimal _leftAmount;
        protected Corporation _corporation;

        #endregion

        #region Constructors

        public Account() { }

        public Account(string id, string name, string currency, SystemIdentifier.AccountType type, SystemIdentifier.AccountStatus status, DateTime createDate, DateTime modifyDate, int editUser, Corporation corporation)
        {
            this.Id = id;
            this._name = name;
            this._currency = currency;
            this._type = type;
            this._status = status;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._corporation = corporation;
            this._initialDate = DateTime.Now;
            this._initialAmount = 0;
            this._leftAmount = 0;
        }

        #endregion

        #region Public Properties

        public virtual string Name
        {
            get { return _name; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
                _name = value;
            }
        }

        public virtual string Currency
        {
            get { return _currency; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Currency", value, value.ToString());
                _currency = value;
            }
        }

        public virtual SystemIdentifier.AccountType Type
        {
            get { return _type; }
            set { _type = value; }
        }

        public virtual SystemIdentifier.AccountStatus Status
        {
            get { return _status; }
            set { _status = value; }
        }

        public virtual DateTime InitialDate
        {
            get { return _initialDate; }
            set { _initialDate = value; }
        }

        public virtual decimal InitialAmount
        {
            get { return _initialAmount; }
            set { _initialAmount = value; }
        }

        public virtual decimal LeftAmount
        {
            get { return _leftAmount; }
            set { _leftAmount = value; }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        #endregion
    }
    #endregion
}